package com.life.goal.application.service;

import com.life.goal.application.assembler.EnglishDataAssembler;
import com.life.goal.application.dto.request.InsertOralBatchRequest;
import com.life.goal.application.dto.request.InsertOralRequest;
import com.life.goal.application.dto.request.InsertWordRequest;
import com.life.goal.domain.entity.OralSentence;
import com.life.goal.domain.support.EnglishDataRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EnglishDataService {

    @Resource
    private EnglishDataRepository englishDataRepository;
    @Resource
    private EnglishDataAssembler englishDataAssembler;

    /**
     * 保存单词
     */
    public void saveWord(InsertWordRequest request) {
        englishDataRepository.saveWord(englishDataAssembler.buildWordBook(request));
    }

    /**
     * 保存口语
     */
    public void saveOral(InsertOralRequest request) {
        englishDataRepository.saveOral(englishDataAssembler.buildOralSentence(request));
    }

    /**
     * 批量新增英语单词
     */
    public void saveWordBatch(List<InsertWordRequest> list) {
        englishDataRepository.saveWordBatch(englishDataAssembler.buildWordBookList(list));
    }

    /**
     * 批量新增英语口语
     */
    public void saveOralBatch(InsertOralBatchRequest request) {
        englishDataRepository.saveOralBatch(englishDataAssembler.buildOralSentenceList(request));
    }

    /**
     * 查询全部oral语句
     */
    public List<OralSentence> queryAllOralSentences() {
        return englishDataRepository.queryAllOralSentences();
    }
}
